package br.com.sisnema.aula2;

import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import android.widget.Toast;
import br.com.sisnema.aula2.dao.ClienteDAO;
import br.com.sisnema.aula2.vo.ClienteVO;

public class Cadastro extends Activity {
	 
	private int quantidade = 0;
	
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.form);
      
    }
    
    public void Salvar_Click(View view){
    	
    	final EditText txtNome = (EditText)findViewById(R.id.editText1);
        final EditText txtEmail = (EditText)findViewById(R.id.editText2);
        
    	if(txtNome.getText().toString().length() <= 0){
    		txtNome.setError("Preencha este campo.");
    		txtNome.requestFocus();
    	} else {
    		ClienteVO vo = new ClienteVO();
    		vo.setNome(txtNome.getText().toString());
    		vo.setEmail(txtEmail.getText().toString());
    		
    		ClienteDAO dao = new ClienteDAO(getBaseContext());
    		
    		if(dao.insert(vo)){
    			Toast.makeText(getBaseContext(), "Inserido com sucesso!", Toast.LENGTH_LONG).show();
    		}
    	}
    }
}